Login = function(){
	var win,fs;

	var buildForm = function(){
		fs = new Ext.form.FormPanel({
			layout:'form',
			defaultType:'textfield',
			defaults:{width:150},
			bodyStyle:'padding:50px 0 0',
			labelWidth:50,
			labelAlign:'right',
			height:200,
			frame:true,
			items:[
			{
				fieldLabel:'帐号',
				name:'username'
			},
			{
				fieldLabel:'密码',
				name:'password',
				inputType:'password'
			}
			]
		});
	};

	var buildWin = function(){
		var panel = new Ext.Panel({
			contentEl:'login'
		});
		win = new Ext.Window({
			el:'win',
			width:380,
			height:230,
			title:'登录系统',
			layout:'column',
			defaults:{border:false},
			items:[{
				width:120,
				items:panel
			},{
				columnWidth:1,
				items:fs
			}],
			buttons:[
			{
				text:'登录',
				handler:login
			},
			{
				text:'取消',
				handler:function(){window.close();}
			}
			]
		});
	};

	var login = function(){
		fs.form.submit({
			waitMsg: '正在登录。。。',
			url:'./?ctrl=members&action=login',
			method:'POST',
			success:function(form,action){
				window.location=J_get("rurl");
			},
			failure:function(form,action){
				Ext.MessageBox.alert('警告','登录失败，请检查帐号密码是否正确。');
			}
		});
	};

	return{
		init:function(){
			buildForm();
			buildWin();
			win.show();
		}
	}
}();
Ext.onReady(Login.init,Login);

